/**
 * @author LKQ
 * @date 2022/1/7 10:20
 * @description 利用特性，左子树值小于根值，右子树值大于根值
 */
public class Solution {
    public static void main(String[] args) {

    }

    public TreeNode searchBST(TreeNode root, int val) {
        while (root != null) {
            if (root.val == val) {
                return root;
            }else if (root.val > val) {
                root = root.left;
            }else if (root.val < val) {
                root = root.right;
            }
        }
        return null;
    }
}
